define(["jed","./config","avalon"], function(Jed,config,avalon){

	// Jed API
	// translate( key ) - Sets the key to translate (often english).
	// onDomain( domain ) - Sets the domain to use in the locale_data.
	// withContext( context ) - Specifies the context prefix for key lookup.
	// ifPlural( num, plural_key ) - Specifies the plural translation path and plural value.
	// fetch( sprintf, style, args ) - the values to interpolate into the response.
	// Jed.sprintf( "I like your %1$s %2$s.", 'red', 'shirt' )

	// gettext API
	// gettext = function ( key )
	// dgettext = function ( domain, key )
	// dcgettext = function ( domain, key, category )
	// ngettext = function ( singular_key, plural_key, value )
	// dngettext = function ( domain, singular_ley, plural_key, value )
	// dcngettext = function ( domain, singular_key, plural_key, value, category )
	// pgettext = function ( context, key )
	// dpgettext = function ( domain, context, key )
	// npgettext = function ( context, singular_key, plural_key, value )
	// dnpgettext = function ( domain, context, singular_key, plural_key, value )
	// dcnpgettext = function ( domain, context, singular_key, plural_key, value, category )

	var langs = {
		"en": require("../translations/en.json"),
		"zh_CN": require("../translations/zh_CN.json")
	}

	function I18n(l){
		this._jed = new Jed(l); 
	}

	I18n.prototype.gettext = function(str){
		return this._jed.translate(str).fetch();
	}
	I18n.prototype.ngettext = function(str1,str2, n){

		return Jed.sprintf(this._jed.ngettext(str1, str2), n);
	}

	
	var i18n = new I18n(_.merge({

		  "missing_key_callback" : function(key) {
		    console.error(key)
		  }
		},langs[config.local]));





	return i18n;
})